﻿<?xml version="1.0" encoding="utf-8"?>
<!--
        作者：          liuleyi
        更新时间：      20170227
        用途：          生成存储过程默认模板
-->
<xsl:stylesheet version="2.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:xs="http://www.w3.org/2001/XMLSchema"
	xmlns:fn="http://www.w3.org/2005/xpath-functions">
	<xsl:output method="text" indent="no" encoding="utf-8" byte-order-mark="no"/>  
	<xsl:template match="/">

	<xsl:variable name="StringTypeDefine" select="document('../model/0101_StringTypeDefine.xml')"/>
	<xsl:variable name="EnumTypeDefine" select="document('../model/0102_EnumTypeDefine.xml')"/>
	<xsl:variable name="BooleanTypeDefine" select="document('../model/0103_BooleanTypeDefine.xml')"/>
	<xsl:variable name="DateTypeDefine" select="document('../model/0104_DateTypeDefine.xml')"/>
	<xsl:variable name="NumberTypeDefine" select="document('../model/0105_NumberTypeDefine.xml')"/>
	<xsl:variable name="IntegerTypeDefine" select="document('../model/0106_IntegerTypeDefine.xml')"/>
<xsl:for-each select="FunNoConfig/FunNo">
<xsl:variable name="fileName" select="concat('./generate/python/template/',lower-case(@code),'.html')"/>
	<xsl:result-document encoding="utf-8"  method="text" href="{$fileName}">
{% extends "base.html" %}
{% block title %}<xsl:value-of select="@label"/>{% endblock %}
{% block content %}
&lt;h1&gt;<xsl:value-of select="@label"/>&lt;/h1&gt;
&lt;hr /&gt;

&lt;table border=&quot;0&quot;&gt;
<xsl:for-each select="Request"><xsl:for-each select="Column">
<xsl:variable name="typeTable" select="@name"/>
<xsl:if test="(position() mod 2)=1">&lt;tr&gt;</xsl:if>

&lt;td width=&quot;150&quot; align=&quot;right&quot;&gt;&lt;p&gt;<xsl:for-each select="$StringTypeDefine//String[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$EnumTypeDefine//Enum[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$BooleanTypeDefine//Boolean[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$DateTypeDefine//Date[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$NumberTypeDefine//Number[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$IntegerTypeDefine//Integer[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each>:&lt;/p&gt;&lt;/td&gt;

&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;<xsl:value-of select="@name"/>&quot;/&gt;&lt;/td&gt;

<xsl:if test="(position() mod 2)=0">&lt;/tr&gt;</xsl:if>
<xsl:if test="position()=last()">&lt;/tr&gt;</xsl:if>
</xsl:for-each></xsl:for-each>
&lt;tr&gt;
&lt;td width=&quot;150&quot; &gt;&lt;input type=&quot;submit&quot; value=&quot;查询&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;hr /&gt;
<xsl:for-each select="Response">
&lt;div class=&quot;row&quot;&gt;
      &lt;div class=&quot;col-md-12&quot;&gt;
          <!-- Advanced Tables -->
          &lt;div class=&quot;card&quot;&gt;
              &lt;div class=&quot;card-action&quot;&gt;
              &lt;div&gt;
              &lt;div class=&quot;card-content&quot;&gt;
                  &lt;div class=&quot;table-responsive&quot;&gt;
                      &lt;table class=&quot;table table-striped table-bordered table-hover&quot; id=&quot;dataTables&quot; border=&quot;1&quot;&gt;
                          &lt;thead&gt;
                              &lt;tr&gt;
<xsl:for-each select="Column">
<xsl:variable name="typeTable" select="@name"/>
&lt;th&gt;<xsl:for-each select="$StringTypeDefine//String[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$EnumTypeDefine//Enum[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$BooleanTypeDefine//Boolean[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$DateTypeDefine//Date[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$NumberTypeDefine//Number[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$IntegerTypeDefine//Integer[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each>&lt;/th&gt;
</xsl:for-each>
                              &lt;/tr&gt;
                          &lt;/thead&gt;
{% if resp.listdata %}
                          &lt;tbody&gt;
    {% for list in resp.listdata %}
      &lt;tr class=&quot;toggler&quot;&gt;
<xsl:for-each select="Column">
&lt;td&gt;{{ list.<xsl:value-of select="@name"/> }}&lt;/td&gt;
</xsl:for-each>
        <li><a href="/polls/{{ question.id }}/">{{ question.question_text }}</a></li>
      &lt;/tr&gt;
    {% endfor %}
                          &lt;/tbody&gt;
{% endif %}
                      &lt;/table&gt;
                  &lt;div&gt;
                  
              &lt;div&gt;
          &lt;div&gt;
          <!--End Advanced Tables -->
      &lt;div&gt;
&lt;div&gt;
</xsl:for-each>
{% endblock %}
	</xsl:result-document>
</xsl:for-each>

</xsl:template>  
</xsl:stylesheet>